package models

import com.jfinal.plugin.activerecord.Model

class SuperUserM: Model<SuperUserM>(){
    companion object{
        val AGENT by lazy{
            SuperUserM()
        }
        const val TABLE_NAME = "su_user"
        const val ID = "id"
        const val USERNAME = "username"
        const val PASSWORD = "password"
        const val EMAIL = "email"
        const val PHONE = "phone"

        fun findUserWithPassword(username: String, password: String) : SuperUserM?{
            val list = AGENT.find("select * from $TABLE_NAME where $USERNAME = ? and $PASSWORD = ?", username, password)
            return if (list.isEmpty()) null else list.first()
        }

        fun findUserByUsername(username: String): SuperUserM?{
            val list = AGENT.find("select * from $TABLE_NAME where $USERNAME = ?", username)
            return if (list.isEmpty()) null else list.first()
        }
    }


}